<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <title>掩模-显示所有省份</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <style>
    body,
    html,
    #container {
        width: 100%;
        height: 100%;
        margin: 0;
        font-family: "微软雅黑";
    }
    </style>
    <script src="https://api.map.baidu.com/api?type=webgl&v=1.0&ak=你的ak"></script>
</head>
<body>
    <div id="container""></div>
</body>
</html>
<script>
var map = new BMapGL.Map('container', {
});
map.centerAndZoom(new BMapGL.Point(106.569189,34.746385), 5);
map.enableScrollWheelZoom()

var points = {
    '山东': {"sw":{"lng":114.51240667748831,"lat":32.89765984404206},"ne":{"lng":123.18342638417589,"lat":39.790794991796915}},
    '天津': {"sw":{"lng":116.21216720316548,"lat":38.488275028567216},"ne":{"lng":118.63059453020064,"lat":40.32551644386831}},
    '北京': {"sw":{"lng":115.33563334335841,"lat":39.38339958219084},"ne":{"lng":117.65603894052243,"lat":41.13044266333082}},
    '江苏': {"sw":{"lng":116.14140184656964,"lat":30.391721815397432},"ne":{"lng":122.28529007999712,"lat":35.48531762742293}},
    '浙江': {"sw":{"lng":117.83590357272202,"lat":26.774593316272494},"ne":{"lng":123.28203506917352,"lat":31.448233371244203}},
    '上海': {"sw":{"lng":120.74983500679882,"lat":30.63713888838736},"ne":{"lng":122.29359260817741,"lat":31.928619811355198}},
    '福建': {"sw":{"lng":115.4320647093136,"lat":23.336799386738342},"ne":{"lng":121.24858100041702,"lat":28.512819255890115}},
    '安徽': {"sw":{"lng":113.93455977733845,"lat":29.18029350909403},"ne":{"lng":120.71929010822126,"lat":34.8629839820749}},
    '江西': {"sw":{"lng":112.65732049723664,"lat":24.264237096369556},"ne":{"lng":119.53134667773024,"lat":30.303764512224312}},
    '河南': {"sw":{"lng":110.11756103529812,"lat":31.037075716387456},"ne":{"lng":117.02569483510885,"lat":36.7036605751727}},
    '河北': {"sw":{"lng":112.08664561892472,"lat":35.767960218588094},"ne":{"lng":121.40399178297938,"lat":42.87784469513076}},
    '广东': {"sw":{"lng":109.34980321463169,"lat":19.007087678225357},"ne":{"lng":117.76615091270174,"lat":26.679865170155242}},
    '香港': {"sw":{"lng":113.79846131765568,"lat":22.00629555302909},"ne":{"lng":114.5534831799305,"lat":22.6993468965993}},
    '海南': {"sw":{"lng":107.84636331617284,"lat":17.445054392696306},"ne":{"lng":111.5858226838271,"lat":20.940442716106837}},
    '湖北': {"sw":{"lng":108.05869415674704,"lat":27.50220299140574},"ne":{"lng":116.5879329434748,"lat":34.72090665110131}},
    '湖南': {"sw":{"lng":108.20476564261614,"lat":24.413905305084494},"ne":{"lng":114.9633358593304,"lat":30.349647084327607}},
    '山西': {"sw":{"lng":108.21357289451892,"lat":34.331913847183415},"ne":{"lng":116.72965143176817,"lat":40.99070780568848}},
    '陕西': {"sw":{"lng":103.14638662734845,"lat":31.373814137238934},"ne":{"lng":113.7519135320812,"lat":39.893792763198206}},
    '重庆': {"sw":{"lng":105.10049490831332,"lat":27.87847229327538},"ne":{"lng":110.48129764924906,"lat":32.48198316140804}},
    '贵州': {"sw":{"lng":103.36455221403061,"lat":24.00730393622239},"ne":{"lng":109.94897412888648,"lat":29.816994980107353}},
    '广西': {"sw":{"lng":104.15906589302904,"lat":19.82354273110784},"ne":{"lng":112.50673342484966,"lat":27.38895118383128}},
    '云南': {"sw":{"lng":97.06739505807782,"lat":20.812598603663876},"ne":{"lng":106.82472686040762,"lat":29.543346004341124}},
    '四川': {"sw":{"lng":96.90053429641252,"lat":24.883564774719378},"ne":{"lng":109.18296432030011,"lat":35.37916343670507}},
    '甘肃': {"sw":{"lng":91.68145094211397,"lat":30.538822223562324},"ne":{"lng":109.65710683056641,"lat":44.55900040140329}},
    '内蒙古': {"sw":{"lng":96.00513822984561,"lat":34.29771324046388},"ne":{"lng":126.95833140219858,"lat":55.571292611521834}},
    '宁夏': {"sw":{"lng":103.17325884108499,"lat":35.06910901045307},"ne":{"lng":108.8759035628169,"lat":39.55775216956929}},
    '西藏': {"sw":{"lng":77.58348038618244,"lat":21.769814779545204},"ne":{"lng":100.31234169794229,"lat":40.83035978679642}},
    '青海': {"sw":{"lng":88.8753190353366,"lat":29.27074638383035},"ne":{"lng":103.85173567982099,"lat":41.32395796513529}},
    '新疆': {"sw":{"lng":72.60607297249815,"lat":32.34813142977824},"ne":{"lng":97.69134493880628,"lat":50.713279748693765}},
    '黑龙江': {"sw":{"lng":119.86200571955143,"lat":42.978846400775915},"ne":{"lng":136.6878368396074,"lat":53.93756512570677}},
    '吉林': {"sw":{"lng":121.25013950612839,"lat":39.728274102699764},"ne":{"lng":131.8837823545246,"lat":47.33312620762936}},
    '辽宁': {"sw":{"lng":118.57327198542508,"lat":38.235792500153885},"ne":{"lng":126.19678663952775,"lat":43.90858931370429}},
    '澳门': {"sw":{"lng":113.50947082015988,"lat":22.074044676055706},"ne":{"lng":113.67257148966727,"lat":22.225805333732573}},
    '台湾': {"sw":{"lng":119.11221595954407,"lat":21.292257092003197},"ne":{"lng":124.9020198365798,"lat":26.520988697616712}},
}


var ps = ['浙江', '上海', '江苏', '福建', '安徽', '黑龙江', '吉林', '辽宁', '山东', '北京', '天津', '河北', '山西', '陕西', '内蒙古', '河南', '宁夏', '湖南', '湖北', '广东', '广西', '四川', '云南',
    '贵州', '西藏', '新疆', '甘肃', '青海', '海南', '香港', '澳门', '台湾', '江西', '重庆']
Array.from(ps).forEach(proname => {
    var point = points[proname]
    if(point) {
        var pStart = new BMapGL.Point(point.ne.lng, point.sw.lat);
        var pEnd = new BMapGL.Point(point.sw.lng, point.ne.lat);
        var bounds = new BMapGL.Bounds(new BMapGL.Point(pStart.lng, pEnd.lat), 
                                        new BMapGL.Point(pEnd.lng, pStart.lat));
        var imgOverlay = new BMapGL.GroundOverlay(bounds, {
            type: 'image',
            url: proname+'.png',
            opacity: 0.5
        });
        map.addOverlay(imgOverlay);
        var imgOverlay = new BMapGL.GroundOverlay(bounds, {
            type: 'image',
            url: proname+'边界.png',
            opacity: 0.5
        });
        map.addOverlay(imgOverlay);

    }
})


  
</script>